from concepts import *


class DateBar(GUIElement):
    calendar    = Attribute()
    day         = calendar._.day
    day_suffix  = calendar._.day_suffix
    month       = calendar._.month_string
    year        = calendar._.year
    year_suffix = calendar._.suffix
    
    @property
    def needs_update(self):
        return self.calendar.is_start_of_day


class CityNameBar(GUIElement):
    city = Attribute()
    name = city._.name
    
    @property
    def description(self):
        if self.city.population  ==     0:
            return 'Unsettled Area'
        elif self.city.population <    10:
            return 'Cottage'                 # (city must work to grow)
        elif self.city.population <   500:
            return 'Hamlet'
        elif self.city.population <  2000:
            return 'Village'
        elif self.city.population < 10000:
            return 'Town'
        else:
            return 'City'


class CityStateBar(GUIElement):
    city       = Attribute()
    money      = city._.money
    population = city._.population
    
    @property
    def surplus(self):
        if self.city.needs_workers:
            return self.city.openings
        else:
            return self.city.unemployed
    
    @property
    def surplus_is_workers(self):
        return not self.city.needs_workers
    
    @property
    def surplus_is_jobs(self):
        return self.city.needs_workers
